package com.wsx.sky.data;

import com.wsx.sky.data.thrift.ThriftSerialization;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author wangshuaixin
 * @Title: com.wsx.sky.data.Compare
 * @Description: TODO
 * @date 2019/03/14
 */
public class Compare {


    public static void main(String[] args) {
        List<String> datas = getData();

        List<DataSerialization> services = getService();
        for (String data : datas) {
            for (DataSerialization service : services) {
                service.serialization(data);
            }
        }

    }

    private static List<DataSerialization> getService() {
        List<DataSerialization> services = new ArrayList<>();
        services.add(new ThriftSerialization());
        return services;
    }

    private static List<String> getData() {
        return Arrays.asList(getTtsContent());
    }

    private static String getTtsContent() {
        String content = null;
        InputStream in = null;
        BufferedReader reader = null;
        try {
            in = Compare.class.getClassLoader().getResourceAsStream("aco_list.txt");
            reader = new BufferedReader(new InputStreamReader(in));
            StringBuilder builder = new StringBuilder();
            String line;
            while((line = reader.readLine()) != null) {
                builder.append(line);
            }
            content = builder.toString();
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (null != reader) {
                try {
                    reader.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        return content;

    }
}
